package com.cbgolf.oa.activity.message;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;
import com.cbgolf.oa.R;
import com.cbgolf.oa.activity.publiz.MainActivity;
import com.cbgolf.oa.base.BaseActivity;
import com.cbgolf.oa.util.DataUtil;
import com.cbgolf.oa.util.DateUtil;
import com.cbgolf.oa.util.TextUtil;
import com.cbgolf.oa.util.Util;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by Administrator on 2017/9/2.
 */

public class PushSuccessActivity extends BaseActivity {

  //top
  @ViewInject(R.id.topBack_ll)
  private View topBack;
  @ViewInject(R.id.title_tv)
  private TextView topTitle;
  @ViewInject(R.id.topRight_tv)
  private TextView topRightTv;
  //body
  @ViewInject(R.id.a_push_success_pushtype_and_time_tv)
  private TextView typeAndTimeTv;
  @ViewInject(R.id.a_push_success_gender_tv)
  private TextView genderTv;
  @ViewInject(R.id.a_push_success_user_type_tv)
  private TextView userTypeTv;
  @ViewInject(R.id.a_push_success_msg_tv)
  private TextView msgTv;

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.a_push_success);
  }

  @Override
  protected void findViews() {
    x.view().inject(this);
  }

  @Override
  protected void setViews() {
    topTitle.setText("推送成功");
    topBack.setVisibility(View.GONE);
    topRightTv.setVisibility(View.VISIBLE);
    topRightTv.setText("关闭");
    Intent intent = getIntent();
    String pushType = DataUtil.getStringExtra(intent, "pushType");
    String pushTime = DataUtil.getStringExtra(intent, "pushTime");
    String gender = DataUtil.getStringExtra(intent, "gender");
    String userType = DataUtil.getStringExtra(intent, "userType");
    String msg = DataUtil.getStringExtra(intent, "msg");
    if (Util.isNull(pushTime)) {
      pushTime = DateUtil.stampToDate(String.valueOf(System.currentTimeMillis()),
          DateUtil.formatWithbias);
    }
    typeAndTimeTv.setText(TextUtil.Text(pushType) + "  " + pushTime);
    genderTv.setText(TextUtil.Text(gender));
    userTypeTv.setText(TextUtil.Text(userType));
    msgTv.setText(TextUtil.Text(msg));
  }

  @Override
  protected void setListener() {
    topRightTv.setOnClickListener(v -> {
      mStartActivity(MainActivity.class);
      finish();
    });


  }
}
